const {
  recognizeLiveAudio,
  getAudioStream,
} = require("./speechRecognition.js");
const {chatWithOllama} = require("./ollama.js");
const { ToBaIcon } = require("./baIcon.js");
const rec = recognizeLiveAudio();
let stopRecording= null



const start =()=>{
 stopRecording= getAudioStream(rec, async (msg) => {
      console.log(msg);
    res = await  chatWithOllama('回答我的时候精简一点,然后直接回复我,回答我的问题不能超过40个字,文本如下:'+msg)
    stopRecording&&  stopRecording()
      ToBaIcon({
        text: res ,
        voice: "Microsoft Huihui Desktop",
        speed: 0,
        volume: 100,
      }).then(() => {
        start();
      });
    })

}
// 主函数
function main() {
  // 启动语音识别
start()
}

main();
